package org.hiucung.hlsdownloader.database

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update
import kotlinx.coroutines.flow.Flow

// DownloadItemDao.kt
@Dao
interface M3U8TaskItemDao {
    @Query("SELECT * FROM m3u8_task_items ORDER BY createdAt DESC")
    fun getAll(): Flow<List<M3U8TaskItemEntity>>

    @Query("SELECT * FROM m3u8_task_items WHERE id = :id")
    suspend fun getById(id: String): M3U8TaskItemEntity?

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insert(item: M3U8TaskItemEntity)

    @Update
    suspend fun update(item: M3U8TaskItemEntity)

    @Delete
    suspend fun delete(item: M3U8TaskItemEntity)

    @Query("DELETE FROM m3u8_task_items WHERE id = :id")
    suspend fun deleteById(id: String)
}